<template>
  <div class="manage_page fillcontain">
      <div class="header_container">
        <img src="../assets/stu/icon_title.png" @click="goHome" style="cursor: pointer" />
        <el-dropdown @command="handleCommand" style="float: right;margin-right: 50px">
          <div style="margin-left: 15px;float:left;margin-top: 8px;margin-bottom: 6px"><img style="align-content: center; cursor: pointer;" src="../assets/stu/pic_title_user.png" height="32" width="32"/></div>
          <div style="float: left;vertical-align: middle;line-height: 50px;margin-left: 10px;">{{user.name}}</div>
          <!--<img src="../assets/stu/pic_title_user.png" style="cursor: pointer">-->
          <!--{{user}}-->
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="goProfile">个人资料</el-dropdown-item>
            <el-dropdown-item command="logout">退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
        <!--<el-menu mode="horizontal" :default-active="defaultActive" router class="top-nav">-->
          <!--<el-menu-item index="/platform/myCenter">首页</el-menu-item>-->
          <!--<el-menu-item index="/platform/discussion">E问</el-menu-item>-->
        <!--</el-menu>-->
    <div class="top-nav">
      <ul>
        <li><div @click="goHome" style="cursor: pointer">首页</div></li>
        <li><div @click="goAsk" style="cursor: pointer">讨论区</div></li>
      </ul>
    </div>
    <div class="mycenter">
    <el-row>
      <el-col :offset="1" style="width: 270px">
        <div class="user_icon">
          <img src="../assets/stu/pic_list_user.png"/>
        </div>

        <div  class="nav">
        <el-menu mode="vertical" :default-active="defaultActive" router>
          <el-menu-item-group class="task-nav">
            <template slot="title">
              <p class="title-style"><i class="el-icon-fa el-icon-fa-tasks"></i>
                实训任务</p>
            </template>
            <el-menu-item index="/platform/myTask" class="first-item">
              <i class="el-icon-document"></i>
              我的任务
              <!--<el-badge :value="1"></el-badge>-->
            </el-menu-item>
            <el-menu-item index="/platform/consumptiveMaterial">
              <i class="el-icon-menu"></i>
              耗材管理
            </el-menu-item>
          </el-menu-item-group>
        </el-menu>
        </div>
        <div class="nav">
        <el-menu mode="vertical" :default-active="defaultActive" router>
        <el-menu-item-group class="person-nav">
          <template slot="title">
            <p class="title-style"><i class="el-icon-fa-address-book"></i>
              个人中心</p>
          </template>
          <!--<el-menu-item index="/platform/myExam"  class="first-item">-->
            <!--<i class="el-icon-edit"></i>我的考试-->
            <!--</el-menu-item>-->
            <!--<el-menu-item index="/platform/history">-->
              <!--<i class="el-icon-share"></i>学习足迹-->
            <!--</el-menu-item>-->
            <!--<el-menu-item index="/platform/myMsg">-->
              <!--<i class="el-icon-message"></i>我的消息-->
            <!--</el-menu-item>-->
            <el-menu-item index="/platform/profile">
              <i class="el-icon-fa-address-book"></i>个人资料
            </el-menu-item>
            <el-menu-item index="/platform/passwd">
              <i class="el-icon-setting"></i>修改密码
            </el-menu-item>
          </el-menu-item-group>
        </el-menu>
        </div>
      </el-col>
      <el-col :span="17" style="height: 100%; margin-left: 20px">
        <keep-alive>
          <router-view></router-view>
        </keep-alive>
      </el-col>
    </el-row>
    </div>
    <div class="foot">
        <div class="footer">
          <div style=" margin-top: 15px;float: left;">
            <img src="../assets/stu/icon_title.png"/>
            <div style="margin-top: 15px;width: 450px">
              <span style="width: 100px;color: #979797;font-size: 14px;text-align: left">物联网智慧实训平台是以物联网技术实训作为出发点，搭载E学堂教学信息化，为用户提供完整体系的物联网学习平台。</span>
            </div>
          </div>
          <div class="footer-copyright">
            <table>
              <tr>
                <td style="border:0;vertical-align:middle;height:25px;font-size:15px;color: #979797">©2016-2020
                  北京新大陆时代教育科技有限公司 版权所有
                </td>
              </tr>
            </table>
          </div>
        </div>
      </div>
    </div>
</template>

<script>
  import {getClientUser, clientLogout} from '@/api/api'
  export default {
    data () {
      return {
        myUrl: '',
        user: ''
      }
    },
    computed: {
      defaultActive: function () {
        if (this.$route.path.indexOf('/learn') > 0) {
          return '/platform/myTask'
        }
        return this.$route.path
      }
    },
    created () {
      this.initData()
    },
    methods: {
      goProfile () {
        this.$router.push({path: '/platform/profile'})
      },
      goConsumable () {
        this.$router.push({path: '/platform/consumable'})
      },
      goHome () {
        this.$router.push({path: '/platform/myTask'})
      },
      goAsk () {
        this.$router.push({path: '/platform/discussion'})
      },
      logout () {
        clientLogout({username: this.user.username}).then(res => {
          this.$router.push({path: '/'})
        })
      },
      initData () {
        getClientUser().then(res => {
          if (res.status === 201) {
            // this.$router.push({path: '/'})
          } else {
            this.user = res.data
          }
        })
      },
      handleCommand (command) {
        switch (command) {
          case 'logout':
            this.logout()
            break
          case 'goProfile':
            this.goProfile()
            break
        }
      }
    }
  }
</script>

<style scoped lang="less">
@border-style: 1px solid #f2f2f2;
.user_icon{
  height: 120px;
  margin-top: 20px;
  margin-bottom: 20px;
  border:@border-style;
  img {
    margin: 10px;
  }
}
.top-nav {
  height: 45px;
  background: #499aff;
  ul {
    margin-left: 50px;
    li {
      float: left;
      color: white;
      list-style:none;
      font-size: 18px;
      div {
        width: 100px;
        height: 100%;
        margin-top: 8px;
        margin-left: 50px;
        text-align: center;
      }
    }
  }
  .el-menu-item {
    height: 45px;
    background: #499aff;
    color: white;
  }
}
.mycenter {
  height: 74%;
  min-height: 850px;
}
.nav {
  text-align: center;
  margin-bottom: 20px;
  .el-menu {
    background: white;
    border:@border-style;
    .el-menu-item {
      font-size: 18px;
    }
  }
  .first-item {
    border-top:@border-style;
  }
  .title-style {
    /*margin-top: 0px;*/
    margin-bottom: 12px;
    margin-left: -28px;
    line-height: 100%;
    vertical-align: middle;
    font-size: 20px;
  }
  .task-nav {
    border-top: solid #08c9ab;
    /*background-image: url("../assets/stu/ico_list_task.png");*/
    /*background-position:60px 0px;*/
    /*background-repeat: no-repeat;*/
    .title-style {
      color: #08c9ab;
    }
    .el-menu-item.is-active {
      color: #08c9ab;
    }
  }
  .person-nav {
    border-top: solid #499aff;
    /*background-image: url("../assets/stu/ico_list_user.png");*/
    /*background-position:60px 0px;*/
    /*background-repeat: no-repeat;*/
    .title-style {
      color: #499aff;
    }
    .el-menu-item.is-active {
      color: #499aff;
    }
  }
}

.el-menu-item{
  background: white;
}
.header_container{
  background-color: white;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 20px;
  img {
    margin-left: 40px
  }
}
.foot {
  /*height: 20%;*/
  /*margin-top: 10px;*/
  /*position: absolute;*/
  /*bottom: 0;*/
  width: 100%;
  height: 186px;
  /*background: #e0e6ef;*/
}

.footer {
  position: relative;
  width: 1200px;
  left: 0;
  bottom: 0;
  margin: 0 auto;
}
.footer-copyright {;
  margin-right: 60px;
  float: right;
  margin-top: 100px;
  overflow: hidden;
  font-size: 15px;
  font-family: "Microsoft YaHei";
  text-align: center;
}

</style>

